package com.lagou;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.io.IOException;
import java.util.HashSet;

public class Code {

    public static void main(String[] args) throws IOException {

        JedisPoolConfig config = new JedisPoolConfig();

        HashSet<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();

        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7001));
        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7002));
        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7003));
        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7004));
        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7005));
        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7006));
        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7007));
        jedisClusterNode.add(new HostAndPort("192.168.80.121", 7008));

        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);

        jcd.set("name:001","zhaoyun");

        String s = jcd.get("name:001");

        System.out.println(s);

        jcd.close();

    }
}
